using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.AccountsDomain;
using ShivamEMR.Model.DataInterfaces.AccountsDataInterf;
using ShivamEMR.Model;

namespace ShivamEMR.Web.Areas.Accounts.Controllers
{   
    public class PaymentTypeController : Controller
    {
		private readonly IPaymentTypeRepository paymenttypeRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public PaymentTypeController() //: this(new PaymentTypeRepository())
        {
            this.paymenttypeRepository = Registry.RepositoryFactory.GetPaymentTypeRepository();
        }

        public PaymentTypeController(IPaymentTypeRepository paymenttypeRepository)
        {
			this.paymenttypeRepository = paymenttypeRepository;
        }

        //
        // GET: /PaymentType/

        public ViewResult Index()
        {
            return View(paymenttypeRepository.All);//Including(paymenttype => paymenttype.Payments));
        }

        //
        // GET: /PaymentType/Details/5

        public ViewResult Details(int id)
        {
            return View(paymenttypeRepository.Find(id));
        }

        //
        // GET: /PaymentType/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /PaymentType/Create

        [HttpPost]
        public ActionResult Create(PaymentType paymenttype)
        {
            if (ModelState.IsValid) {
                paymenttypeRepository.InsertOrUpdate(paymenttype);
                paymenttypeRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /PaymentType/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(paymenttypeRepository.Find(id));
        }

        //
        // POST: /PaymentType/Edit/5

        [HttpPost]
        public ActionResult Edit(PaymentType paymenttype)
        {
            if (ModelState.IsValid) {
                paymenttypeRepository.InsertOrUpdate(paymenttype);
                paymenttypeRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /PaymentType/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(paymenttypeRepository.Find(id));
        }

        //
        // POST: /PaymentType/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var pt = paymenttypeRepository.Find(id);
            paymenttypeRepository.Delete(pt);
            paymenttypeRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

